﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace WebPartCollector.WebPartCollector
{
    [ToolboxItemAttribute(false)]
    public class WebPartCollector : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/WebPartCollector/WebPartCollector/WebPartCollectorUserControl.ascx";

        public Boolean blnQuickLaunch;
        [WebBrowsable(true), WebDisplayName("Quick Launch Items"),
         WebDescription("Select to show all lists added on Quick Launch"),
         Personalizable(PersonalizationScope.Shared),
         Category("Webpart Collector Properties"),
         DefaultValue("true")]

        public Boolean blnQuickLaunchs
        {
            get { return blnQuickLaunch; }
            set { blnQuickLaunch = value; }
        }

        public Boolean blnDocumentLib;
        [WebBrowsable(true), WebDisplayName("Only Document Libraries"),
         WebDescription("Select to show only document Libraries"),
         Personalizable(PersonalizationScope.Shared),
         Category("Webpart Collector Properties"),
         DefaultValue("false")]

        public Boolean blnDocument
        {
            get { return blnDocumentLib; }
            set { blnDocumentLib = value; }
        }

        public Boolean blnList;
        [WebBrowsable(true), WebDisplayName("Only Lists"),
         WebDescription("Select to show only Generic Lists"),
         Personalizable(PersonalizationScope.Shared),
         Category("Webpart Collector Properties"),
         DefaultValue("false")]
        public Boolean blnLists
        {
            get { return blnList; }
            set { blnList = value; }
        }

        public Boolean blnMicrosoft;
        [WebBrowsable(true), WebDisplayName("Only Pages with Custom Web parts"),
         WebDescription("Click to show only pages that have custom Web parts"),
         Personalizable(PersonalizationScope.Shared),
         Category("Webpart Collector Properties"),
         DefaultValue("true")]
        public Boolean blnMicrosofts
        {
            get { return blnMicrosoft; }
            set { blnMicrosoft = value; }
        }

        public Boolean blnForms;
        [WebBrowsable(true), WebDisplayName("Do not include Default pages"),
         WebDescription("Select to remove all Default pages"),
         Personalizable(PersonalizationScope.Shared),
         Category("Webpart Collector Properties"),
         DefaultValue("true")]
        public Boolean blnForm
        {
            get { return blnForms; }
            set { blnForms = value; }
        }
        //private string strListContains;

        protected override void CreateChildControls()
        {
            WebPartCollectorUserControl control = (WebPartCollectorUserControl)Page.LoadControl(_ascxPath);
            control.blnDocumentLib = blnDocument;
            control.blnList = blnList;
            control.blnQuickLaunch = blnQuickLaunch;
            control.blnMicrosoft = blnMicrosoft;
            control.blnForm = blnForm;                     
            Controls.Add(control);
        }
    }
}
